import { createRouter, createWebHashHistory, createWebHistory,RouteRecordRaw, createMemoryHistory } from 'vue-router'

const routes:Array<RouteRecordRaw> = [
    {
        path: '/',
        // name:'Login',
        component: () => import('../components/footer.vue'),
        children:[
            {
                path: '',
                name:'Login',
                component: () => import('../components/login.vue')
            },
            {
                // path: '/reg/:id',
                path: '/reg',
                name:'Reg',
                component: () => import('../components/reg.vue')
            }
        ]
    },
    {
        path:'/root',
        name:'Root',
        component:()=>import('../components/root.vue'),
        // redirect:'/root/user2',
        // redirect:{
        //     path:'/root/user2'
        // },
        alias:['/root1','/root2','/root3'],
        redirect:to=>{
            console.log(to,'=====>to')
            return {
                path:'/root/user2',
                query:{
                    name:'tangshao',
                    age:23
                }
            }
        },
        children:[
            {
                path:'/root/user1',
                components:{
                    default:()=>import('../components/A.vue')
                },
            },
            {
                path:'/root/user2',
                components:{
                    bbb:()=>import('../components/B.vue'),
                    ccc:()=>import('../components/C.vue')
                }
            }
        ]
    }


]

const router = createRouter({
    history: createWebHistory(),//history.pushState
    // history: createWebHashHistory(),//localtion.hash
    routes,
})

export default router